package pub.cleangao.codegen;


import lombok.extern.slf4j.Slf4j;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import pub.cleangao.codegen.literal.CodeOutput;


@Mojo(name = "MicroService", defaultPhase = LifecyclePhase.NONE)
@Slf4j
public class MicroService extends AbstractMojo {

    @Parameter(property = "rootPath", name = "rootPath", defaultValue = "${basedir}")
    private String rootPath;

    @Override
    public void execute() throws MojoExecutionException, MojoFailureException {
        try {
            CodeOutput.generateCodeLiteral(rootPath, false);
            log.info("SUCCESS");
        } catch (Exception e) {
            e.printStackTrace();
            log.error(e.getMessage());
        }
    }

}
